package com.yunfei.yunhetong.prodInfoDtl.service.impl;
import java.util.*;
import com.yunfei.utils.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.yunfei.utils.BaseException;
import com.yunfei.utils.log.BaseLog;
import com.yunfei.utils.string.StringUtil;
import com.yunfei.utils.id.IdUtils;
import com.yunfei.mapper.aiiidb.ProdInfoDtlMapper;
import com.yunfei.yunhetong.prodInfoDtl.bo.*;
import com.yunfei.yunhetong.prodInfoDtl.entity.*;
import com.yunfei.yunhetong.prodInfoDtl.service.*;
import com.yunfei.yunhetong.prodInfoDtl.service.impl.*;
   /**
    *@tablename prodinfodtl
    *@author zhengyunfei
    *@createDate Fri Sep 27 17:02:24 CST 2019
    */ 
	@Service("prodinfodtlService")
	public class ProdInfoDtlServiceImpl implements ProdInfoDtlService{
	@Autowired
	private ProdInfoDtlMapper prodInfoDtlMapper;
	/**
	*新增
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public String add(ProdInfoDtlBo bo){
	String backInfo="保存成功";
	String id="";
		try{
			ProdInfoDtlEntity entity=ProdInfoDtlBo.boToEntity(bo);
			id= IdUtils.getId();
			prodInfoDtlMapper.add(entity);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "add 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return id;
}
	/**
	*新增
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public String batchInsert(List list){
	String backInfo="保存成功";
	String id="";
		try{
			prodInfoDtlMapper.add(list);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "batchInsert 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return id;
}
	/**
	*修改
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public String update(ProdInfoDtlBo bo){
	String backInfo="修改成功";
		try{
			ProdInfoDtlEntity entity=ProdInfoDtlBo.boToEntity(bo);
			prodInfoDtlMapper.update(entity);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "update更新失败", e);
			 throw new BaseException("更新！",e);
		}
		return backInfo;
}
	/**
	*删除
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public String delete(String id){
	String backInfo="删除成功";
		try{
			Map<String,Object> map=new HashMap<String, Object>();
			map.put("id",id.split(","));
			prodInfoDtlMapper.delete(map);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "add 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return backInfo;
}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public ProdInfoDtlBo findById(String id){
		ProdInfoDtlEntity entity=null;
		ProdInfoDtlBo bo=null;
		try{
			entity=(ProdInfoDtlEntity)prodInfoDtlMapper.findById(id);
		if(!StringUtil.isNullOrEmpty(entity)){
				bo=ProdInfoDtlBo.entityToBo(entity);
			}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
	}
		return bo;
	}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public ProdInfoDtlBo findByMap(Map queryMap){
		ProdInfoDtlEntity entity=null;
		ProdInfoDtlBo bo=null;
		try{
			entity=(ProdInfoDtlEntity)prodInfoDtlMapper.findByMap(queryMap);
			if(!StringUtil.isNullOrEmpty(entity)){
				bo=ProdInfoDtlBo.entityToBo(entity);
			}
		}catch(Exception e){
			BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return bo;
}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public ProdInfoDtlBo findByBo(ProdInfoDtlBo param){
		ProdInfoDtlEntity entity=null;
		ProdInfoDtlBo bo=null;
		try{
			entity=(ProdInfoDtlEntity)prodInfoDtlMapper.findByBo(param);
			if(!StringUtil.isNullOrEmpty(entity)){
				bo=ProdInfoDtlBo.entityToBo(entity);
			}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return bo;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public List<ProdInfoDtlBo> findAllList(ProdInfoDtlBo map){
		List<ProdInfoDtlBo> boList=new ArrayList<ProdInfoDtlBo>();
		List<ProdInfoDtlEntity> entityList=new ArrayList<ProdInfoDtlEntity>();
		try{
					entityList=prodInfoDtlMapper.findAllList( map);
				for(int i=0;i<entityList.size();i++){
					ProdInfoDtlEntity entity=entityList.get(i);
					ProdInfoDtlBo bo=ProdInfoDtlBo.entityToBo(entity);
					boList.add(bo);
				}
		}catch(Exception e){
				BaseLog.e(this.getClass(), "findAllList 查询失败", e);
				throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public List<ProdInfoDtlBo> findAllList(Map<String,Object> map){
		List<ProdInfoDtlBo> boList=new ArrayList<ProdInfoDtlBo>();
		List<ProdInfoDtlEntity> entityList=new ArrayList<ProdInfoDtlEntity>();
		try{
				entityList=prodInfoDtlMapper.findAllList( map);
			for(int i=0;i<entityList.size();i++){
				ProdInfoDtlEntity entity=entityList.get(i);
				ProdInfoDtlBo bo=ProdInfoDtlBo.entityToBo(entity);
				boList.add(bo);
			}
		}catch(Exception e){
			BaseLog.e(this.getClass(), "findAllList 查询失败", e);
		throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public List<ProdInfoDtlBo> findAllListPage(ProdInfoDtlBo param){
		List<ProdInfoDtlBo> boList=new ArrayList<ProdInfoDtlBo>();
		List<ProdInfoDtlEntity> entityList=new ArrayList<ProdInfoDtlEntity>();
		try{
		entityList=prodInfoDtlMapper.findAllListPage(param);
			for(int i=0;i<entityList.size();i++){
				ProdInfoDtlEntity entity=entityList.get(i);
				ProdInfoDtlBo bo=ProdInfoDtlBo.entityToBo(entity);
				boList.add(bo);
		}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findAllList 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Fri Sep 27 17:02:24 CST 2019
	*/
	public int count(ProdInfoDtlBo bo){
		int count=0;
		try{
			    ProdInfoDtlEntity entity=ProdInfoDtlBo.boToEntity(bo);
			    count=(Integer)prodInfoDtlMapper.count(entity);
			}catch(Exception e){
				 BaseLog.e(this.getClass(), "findById 查询失败", e);
				 throw new BaseException("查询！",e);
			}
		return count;
	}
}

